import { createApp, Component } from 'vue';
import App from './App.vue';
import 'reset-css';
import './styles/main.scss';
import { store, key } from './store';
import router from './router';
import { traceInitVue, tracePlugin } from '@x-tech/fe-trace-sdk-web';
import * as packagejson from '../package.json';
import { numberWithCommas } from '@/utils/filters';
import { isWx } from '@/utils/index';
import VConsole from 'vconsole';
import './helper/initVant';


isWx().then(res => {
    if (res !== 'mini-wx') {
        try {
            import('@x-tech/jssdk'); // xcBridge
        } catch (error) {
            console.log(error);
        }
    }
}).catch(() => undefined);

const tracer = traceInitVue(
    'app', // 这个是包裹整个应用的rootElement的id 一般来说彪马内嵌项目 是传'app-base'字符 一般vue 项目传'app'字符 ，也可以直接把当前rootElement元素传进来eg：document.querySelector("XX")
    {
        // productCode: 'PORTAL',// 根据统一后台配置的code 具体项目可以先联系谢彪
        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
        productVersion: packagejson.version,
        env: window.XCConfig.VUE_APP_ENV,
        productCode: 'digital-publish-sales-tools-h5',
        vueVersion: undefined,
    }
);

if (window.XCConfig.VUE_APP_ENV !== 'prod') {
    const vConsole = new VConsole();
    console.log(vConsole);
}

const app = createApp(App as unknown as Component);

app.config.globalProperties.$numberWithCommas = numberWithCommas;

app.use(tracePlugin, { tracer }).use(router).use(store, key).mount('#app');
